﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZXIMEW.DAL.Base;
using ZXIMEW.Models.DModels;

namespace ZXIMEW.DAL
{
    /// <summary>
    /// 获取指定用户的角色列表
    /// </summary>
    public class RoleDAL : BaseDAL<RoleInfo>
    {
        public List<RoleInfo> GetUserRoleList(int userId)
        {
            string sql = $"select r.RoleId,r.RoleName,r.IsAdmin from UserRoleInfos ur inner join RoleInfos r on ur.RoleId=r.RoleId where UserId={userId}";
            DataTable dt = GetDt(sql, 1);
            List<RoleInfo> roleList = DbConvert.DataTableToList<RoleInfo>(dt, "RoleId,RoleName,IsAdmin");
            return roleList;
        }
    }
}
